import { useState, useEffect } from "react";

export function useDeviceMode() {
  const [mobile, setMobile] = useState(false);
  function resizeHandler() {
    let width = window.screen.availWidth || window.outerWidth;
    if (width < 768) {
      setMobile(true);
    } else {
      setMobile(false);
    }
  }

  useEffect(() => {
    resizeHandler();
    // window.addEventListener("resize", resizeHandler);
    // return () => {
    //   window.removeEventListener("resize", resizeHandler);
    // };
  }, []);
  return mobile;
}
